package com.website.common.vo;

import java.util.ArrayList;
import java.util.List;

/**
 * 分页
 *
 * @author zhangshuw
 * @date 2017/7/9
 */
public class Page<T> {

    public static final int DEFAULT_PAGE_SIZE = 15;

    private long count = 0;
    private List<T> data = new ArrayList<>();
    private int page = 1;
    private int limit = DEFAULT_PAGE_SIZE;

    public Page(){}

    public Page(int pageNo, int pageSize) {
        this.page = pageNo;
        this.limit = pageSize;
    }

    public long getCount() {
        return count;
    }

    public void setCount(long count) {
        this.count = count;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }
    public int getLimit() {
        return limit;
    }
    public void setLimit(int limit) {
        this.limit = limit;
    }

    /**
     * 根据pageNo和pageSize计算当前页第一条记录在总结果集中的位置,序号从1开始.
     */
    public int getFirst() {
        return ((page - 1) * limit);
    }
}
